//Wrapper for EE::Image
#pragma once
#include "stdafx.h"

namespace EsenthelNet
{
	///<summary>Image Type, comments specify in which mode the type is available (Soft:Software, DX9:DirectX9, DX10+:DirectX10+, GL:OpenGL)</summary>
	public enum class ImageType {
		///<summary>None</summary>
		IMAGE_NONE,

		///<summary>32-bit (r,g,b,a), Soft, DX9, DX10+, GL</summary>
		IMAGE_B8G8R8A8,  
		///<summary>32-bit (r,g,b,a), Soft,DX10+, GL</summary>
		IMAGE_R8G8B8A8,  
		///<summary>24-bit (r,g,b,1), Soft</summary>
		IMAGE_R8G8B8  ,  
		///<summary>16-bit (r,g,0,1), Soft, DX10+, GL</summary>
		IMAGE_R8G8    ,  
		///<summary>8-bit (r,0,0,1), Soft, DX10+, GL</summary>
		IMAGE_R8      ,   

		///<summary>8-bit alpha (0,0,0,a), Soft, DX9, DX10+, GL</summary>
		IMAGE_A8  ,   
		///<summary>8-bit luminance (l,l,l,1), Soft, DX9, GL</summary>
		IMAGE_L8  ,   
		///<summary>16-bit (l,l,l,a), Soft, DX9, GL</summary>
		IMAGE_L8A8,  

		///<summary>DXT3 1:4 lossy RGBA compression with sharp  alpha transitions, DX9, DX10+, GL</summary>
		IMAGE_DXT3,  
		///<summary>DXT5 1:4 lossy RGBA compression with smooth alpha transitions, DX9, DX10+, GL</summary>
		IMAGE_DXT5,  

		///<summary>8-bit integer, Soft</summary>
		IMAGE_I8   ,       
		///<summary>16-bit integer, Soft</summary>
		IMAGE_I16  ,      
		///<summary>24-bit integer, Soft</summary>
		IMAGE_I24  ,      
		///<summary>32-bit integer, Soft</summary>
		IMAGE_I32  ,      
		///<summary>16-bit float, Soft, DX9, DX10+, GL</summary>
		IMAGE_F16  ,      
		///<summary>32-bit float, Soft, DX9, DX10+, GL</summary>
		IMAGE_F32  ,      
		///<summary>2 x 16-bit float ( 32-bit total), Soft, DX9, DX10+, GL</summary>
		IMAGE_F16_2,  
		///<summary>2 x 32-bit float ( 64-bit total), Soft, DX9, DX10+, GL</summary>
		IMAGE_F32_2,  
		///<summary>3 x 16-bit float ( 48-bit total), Soft</summary>
		IMAGE_F16_3,  
		///<summary>3 x 32-bit float ( 96-bit total), Soft</summary>
		IMAGE_F32_3,  
		///<summary>4 x 16-bit float ( 64-bit total), Soft, DX9, DX10+, GL</summary>
		IMAGE_F16_4, 
		///<summary>4 x 32-bit float (128-bit total), Soft, DX9, DX10+, GL</summary>
		IMAGE_F32_4
	};

	///<summary>Image Mode</summary>
	public enum class ImageMode {
		///<summary>Hardware 2D   Texture</summary>
		IMAGE_2D  , 
		///<summary>Hardware 3D   Texture</summary>
		IMAGE_3D  ,
		///<summary>Hardware Cube Texture</summary>
		IMAGE_CUBE, 
		///<summary>Software Image (this type is used for software processing only - it can't be drawn on the screen)</summary>
		IMAGE_SOFT,  
	};

	///<summary>Image (Texture)</summary>
	public ref class Image {
	internal:
		//Image(EE::Image img) {
		//	image = new EE::Image();
		//	*image = img;
		//}
		Image(EE::Image* img) {
			image = img;
		}
		EE::Image* image;
	public:
		Image() {
			image = new EE::Image();
		}
		~Image() {
			image->del();
			delete image;
		}

		property int Width {
			int get() {
				return image->x();
			}
		}
		property int Height {
			int get() {
				return image->y();
			}
		}
		property int Depth {
			int get() {
				return image->z();
			}
		}


		void Load(System::String^ str) {
			image->load(ToEEStr(str));
		}

		//Methods:
		void Draw(float x, float y, float w, float h) {
			image->draw(x, y, w, h);
		}

		void Import(System::String^ name, EsenthelNet::ImageType type, EsenthelNet::ImageMode mode) {
			image->Import(ToEEStr(name), (Int)type, (Int)mode);
		}

		///<summary>Gets a Image from the Cache.</summary>
		static EsenthelNet::Image^ Cache(System::String^ s) {
			return gcnew EsenthelNet::Image(EE::Images(ToEEStr(s)));
		}

		
	};
}

#define PropImage(name, var) property EsenthelNet::Image^ name { EsenthelNet::Image^ get() { return gcnew EsenthelNet::Image(var); } void set(EsenthelNet::Image^ img) { var = img->image; }}